﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TestWork1Example
{
    class Program
    {
        static void Main(string[] args)
        {
            EightTask();
        }

        static void DrawBorder(int height, int width, char ch)
        {
            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {

                    if(i==0 || i == height-1)
                        Console.Write(ch);
                    else if (j==0 || j == width-1)
                        Console.Write(ch);
                    else
                    {
                        Console.Write(' ');
                    }

                }
                Console.WriteLine();
            }
        }

        public static int[] GenerateArray(int size)
        {
            int[] array = new int[size];
            Random rnd = new Random();
            for (int i = 0; i < size; i++)
            {

                array[i] = rnd.Next(1, 11);
                Console.Write("{0} ", array[i]);
            }
            return array;

        }

        public static void EightTask()
        {
            int[] myArray = GenerateArray(10);

            Console.WriteLine();

            int max = myArray.Max();
            int min = myArray.Min();
            int maxPosition = Array.IndexOf(myArray, max);
            int minPosition = Array.IndexOf(myArray, min);
            int counter = 0;

            for (int i = 0; i < myArray.Length; i++)
            {
                if (myArray[i] == max || myArray[i] == min)
                    counter++;
            }

            //for (int i = 0; i < myArray.Length; i++)
            //{
            //    if (max < myArray[i])
            //    {
            //        max = myArray[i];
            //        maxPosition = i;
            //    }
            //    if (min > myArray[i])
            //    {
            //        min = myArray[i];
            //        minPosition = i;
            //    }
            //}

            Console.WriteLine("min: {0}, minPos: {1}", min, minPosition);
            Console.WriteLine("max: {0}, maxPos: {1}", max, maxPosition);
            Console.WriteLine("Counter: {0}", counter);
        }
    }
}
